home *** CD-ROM | disk | FTP | other *** search
/ Sky at Night 2007 June / SAN CD 6-2007 CD-ROM 25.iso / pc / Software / AstroGrav_Win / Java / jre1.6.0 / lib / rt.jar / sun / java2d / Disposer.class (.txt) < prev    next >
Encoding:
Java Class File  |  2006-11-29  |  2.8 KB  |  96 lines

  1. package sun.java2d;
  2.  
  3. import java.lang.ref.PhantomReference;
  4. import java.lang.ref.Reference;
  5. import java.lang.ref.ReferenceQueue;
  6. import java.lang.ref.WeakReference;
  7. import java.security.AccessController;
  8. import java.util.Hashtable;
  9. import sun.security.action.GetPropertyAction;
  10. import sun.security.action.LoadLibraryAction;
  11.  
  12. public class Disposer implements Runnable {
  13.    private static final ReferenceQueue queue = new ReferenceQueue();
  14.    private static final Hashtable records = new Hashtable();
  15.    private static Disposer disposerInstance;
  16.    public static final int WEAK = 0;
  17.    public static final int PHANTOM = 1;
  18.    public static int refType = 1;
  19.  
  20.    public static void addRecord(Object var0, long var1, long var3) {
  21.       disposerInstance.add(var0, new DefaultDisposerRecord(var1, var3));
  22.    }
  23.  
  24.    public static void addRecord(Object var0, DisposerRecord var1) {
  25.       disposerInstance.add(var0, var1);
  26.    }
  27.  
  28.    synchronized void add(Object var1, DisposerRecord var2) {
  29.       if (var1 instanceof DisposerTarget) {
  30.          var1 = ((DisposerTarget)var1).getDisposerReferent();
  31.       }
  32.  
  33.       Object var3;
  34.       if (refType == 1) {
  35.          var3 = new PhantomReference(var1, queue);
  36.       } else {
  37.          var3 = new WeakReference(var1, queue);
  38.       }
  39.  
  40.       records.put(var3, var2);
  41.    }
  42.  
  43.    public void run() {
  44.       while(true) {
  45.          try {
  46.             Reference var1 = queue.remove();
  47.             ((Reference)var1).clear();
  48.             DisposerRecord var2 = (DisposerRecord)records.remove(var1);
  49.             var2.dispose();
  50.             Object var4 = null;
  51.             Object var5 = null;
  52.          } catch (Exception var3) {
  53.             System.out.println("Exception while removing reference: " + var3);
  54.             var3.printStackTrace();
  55.          }
  56.       }
  57.    }
  58.  
  59.    private static native void initIDs();
  60.  
  61.    public static void addReference(Reference var0, DisposerRecord var1) {
  62.       records.put(var0, var1);
  63.    }
  64.  
  65.    public static void addObjectRecord(Object var0, DisposerRecord var1) {
  66.       records.put(new WeakReference(var0, queue), var1);
  67.    }
  68.  
  69.    public static ReferenceQueue getQueue() {
  70.       return queue;
  71.    }
  72.  
  73.    // $FF: synthetic method
  74.    static Disposer access$000() {
  75.       return disposerInstance;
  76.    }
  77.  
  78.    static {
  79.       AccessController.doPrivileged(new LoadLibraryAction("awt"));
  80.       initIDs();
  81.       String var0 = (String)AccessController.doPrivileged(new GetPropertyAction("sun.java2d.reftype"));
  82.       if (var0 != null) {
  83.          if (var0.equals("weak")) {
  84.             refType = 0;
  85.             System.err.println("Using WEAK refs");
  86.          } else {
  87.             refType = 1;
  88.             System.err.println("Using PHANTOM refs");
  89.          }
  90.       }
  91.  
  92.       disposerInstance = new Disposer();
  93.       AccessController.doPrivileged(new 1());
  94.    }
  95. }
  96.